#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<map>
using namespace std;
int main()
{
	map<string,string>mp;
	map<string,string>::iterator i;
	char a[30],b[15],c[15];
	while(gets(a)&&a[0]!='\0')
	{
		sscanf(a,"%s%s",&b,&c);
		string s1(b);
		string s2(c);		
		mp[s2]=s1;	
	}
	string str;
	while(getline(cin,str))
	{
		if(str[0]=='\000')break;
		i=mp.find(str);
		if(i!=mp.end())cout<<mp[str]<<endl;
		else printf("eh\n");
		//cout<<str<<endl;
	}
	return 0;
}

